<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<h2>history03</h2>
<button>回退</button>
<button>回退2</button>

<h1></h1>
<h3></h3>
<script>
    document.querySelectorAll('button')[0].onclick = function () {
// 回退
        window.history.back()
    }


    document.querySelectorAll('button')[1].onclick = function () {
        // 前进  参数  2  前进2步  -2 后退2步
        window.history.go(-2)
    }

    let username = window.localStorage.getItem('username')
    document.querySelector('h1').innerText = username

    let pwd = window.sessionStorage.getItem('password')
    document.querySelector('h3').innerText = pwd

</script>

</body>
</html>
